﻿
$(function () {
    $('#Mvp').change(function () {
        ValidateMvp(this);
    });
});

function AddTeam() {
    var name = $('#TeamList option:selected').text();
    var id = $('#TeamList option:selected').val();
    if (id != null && id != 0) {
        //var check = "<input type='checkbox' id='Enabled' name='Enabled' />";
        $("#TeamList option:selected").remove();

        var row = "<tr><td><input id='TeamId' name='TeamId' type='hidden' value='"+id+"'>"+name+"</td>";
        row += "<td class='center'><select id='Enabled' name='Enabled' style='width:50px'>";
        row += "<option selected='selected'>true</option><option>false</option></select></td></tr>";

        $('#TeamsList').append(row);

//        $('<input>').attr({
//            type: 'hidden',
//            id: 'TeamId',
//            name: 'TeamId',
//            value: id
//        }).appendTo('#playerForm');
    }
}

function ValidateMvp(element) {
    var mvp = $(element).val();
    var reg = new RegExp("^[0-9]+$");

    if (mvp == null || mvp == '' || !reg.test(mvp)) {
        $(element).val('0');
    }
}
